package com.augurit.gzcgwsp.sendNotice.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.augurit.gis.edit.EditService;
import com.augurit.gzcgwsp.sendNotice.dao.YwClosecaseDao;
import com.augurit.gzcgwsp.sendNotice.entity.YwClosecase;
import com.augurit.gzcgwsp.sendNotice.service.IYwClosecaseService;
import com.augurit.common.syslog.tool.SysTraceLogWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Service
@Transactional
public class YwCloseServiceImpl  implements IYwClosecaseService{
	Logger logger = (Logger) LoggerFactory.getLogger(YwCloseServiceImpl.class);
	@Autowired
	private YwClosecaseDao ywClosecaseDao;
	@Autowired
	private EditService wfEditService; 
	/**
	 * 获取 ywMtbjlshInfo
	 * @param id 
	 */
	public YwClosecase getYwClosecase(Long id) {
		return ywClosecaseDao.get(id);
	}
	
	public List<YwClosecase> getYwClosecaseList(){
		return ywClosecaseDao.getNoticeYwClosecase();
	}
	
	public void changState(long id){
		ywClosecaseDao.changState(id);
	}
	
	/**
     * 保存对象
     */
    public void saveEntity(YwClosecase ywClosecase){
    	ywClosecaseDao.save(ywClosecase);
    }
	
	public void changeAllCaseState(){
	    List<YwClosecase> list=ywClosecaseDao.getNoticeYwClosecase();
	    int length=list.size();
	    for(int i=0;i<length;i++)
	    {
	    	YwClosecase ywClosecase=list.get(i);
	    	try {
				wfEditService.savePointProperty("isClose,1", wfEditService.getServiceName(ywClosecase.getCasetype()), "MapServer", 0,ywClosecase.getAcceptNo());
				changState(ywClosecase.getId());
	    	}catch(Exception e){
	    		logger.error("(接口)修改GIS案件状态异常"+SysTraceLogWriter.MESSAGE_SEPARATOR + e.getMessage(), e);
				System.out.println("修改GIS案件状态出错-------------------------");
			}
	    }
	}
}
